package com.reger.l2cache.bloomfilter.hash;

import com.reger.l2cache.bloomfilter.Hash;

public class AdditiveHash implements Hash {

	private final long cap;

	public AdditiveHash(long cap) {
		super();
		this.cap = cap;
	}

	@Override
	public long hash(String data) {
		long hash;
		int i;
		for (hash = data.length(), i = 0; i < data.length(); i++) {
			hash += data.charAt(i);
		}
		return (hash & (cap - 1));
	}

}
